package com.woniuxy.carlife.carlifenewcomplaintsweb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.carlife.carlifecommonsweb.util.CopyUtil;
import com.woniuxy.carlife.carlifenewcomplaintsdomain.dto.StoreFeedbackDto;
import com.woniuxy.carlife.carlifenewcomplaintsdomain.param.StoreFeedbackParam;
import com.woniuxy.carlife.carlifenewcomplaintsweb.domain.StoreFeedback;
import com.woniuxy.carlife.carlifenewcomplaintsweb.mapper.StoreFeedbackMapper;
import com.woniuxy.carlife.carlifenewcomplaintsweb.service.StoreFeedbackService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yp
 * @ClassName:StoreFeedbackServiceImpl
 * @Description:门店投诉回馈服务
 * @date 2021/4/7 2:32
 **/
@Service
public class StoreFeedbackServiceImpl extends ServiceImpl<StoreFeedbackMapper, StoreFeedback> implements StoreFeedbackService {

    @Resource
    private StoreFeedbackMapper storeFeedbackMapper;


    /*
     * 功能描述〈添加投诉回馈〉
     * @author:yp
     * @param:StoreFeedbackParam
     * @return:
     * @Date 2021/4/12 16:22
     * @throws
     */
    @Override
    public int addStoreFeedback(StoreFeedbackParam storeFeedbackParam) {
    StoreFeedback storeFeedback = CopyUtil.getOne(storeFeedbackParam,StoreFeedback.class);
    int num = storeFeedbackMapper.insert(storeFeedback);
        return num;
    }


    /*
     * 功能描述〈查询投诉回馈〉
     * @author:yp
     * @param:StoreFeedbackParam
     * @return:List<StoreFeedbackDto>
     * @Date 2021/4/12 16:42
     * @throws
     */
    @Override
    public List<StoreFeedbackDto> findStoreFeedback(StoreFeedbackParam storeFeedbackParam) {
        QueryWrapper<StoreFeedback> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",storeFeedbackParam.getUserId());
        List<StoreFeedback> list = storeFeedbackMapper.selectList(wrapper);
        List<StoreFeedbackDto> list1 = CopyUtil.getList(list,StoreFeedbackDto.class);
        return list1;
    }
}
